﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
    	<title>Job Scheduler 列表</title>
<jsp:include page="common/header.jsp"/>
		<script type="text/javascript">
			function createTabBar(htmlDiv1) {
				var tabbar = new dhtmlXTabBar(htmlDiv1, "top");
				tabbar.setSkin('dhx_skyblue');
				tabbar.setImagePath("static/dhtmlx/imgs/");
				tabbar.addTab("a1", "调度信息", "100px");tabbar.setContent("a1", "scheduler");
				tabbar.addTab("a2", "依赖触发信息", "100px");tabbar.setContent("a2", "dependency");
				tabbar.enableAutoSize(true, true);
				tabbar.setTabActive("a1");
			}
			
			$(function(){
				createTabBar('TabBarDiv');
			});
		</script>
	</head>
	<body>
<jsp:include page="common/body-header.jsp"/>
		<div id="TabBarDiv" style="width:100%; height:90px;"></div>
		<table id="scheduler">
			<tr>
				<th rowspan="2">Submitter</th>
				<th rowspan="2">Type</th>
				<th rowspan="2">Definition</th>
				<th rowspan="2">Description</th>
				<th colspan="4">Launch Job</th>
				<th rowspan="2">Start<br>Time</th>
				<th rowspan="2">End<br>Time</th>
				<th rowspan="2">Next<br>Fire Time</th>
				<th rowspan="2">Previous<br>Fire Time</th>
				<th rowspan="2">Final<br>Fire Time</th>
				<th rowspan="2">Misfire<br>Instruction</th>
			</tr>
			<tr>
				<th>Type</th>
				<th>Name</th>
				<th>Description</th>
				<th>Parameters</th>
			</tr>
<c:forEach var="trigger" items="${triggers}">
	<c:set var="conf" value='${ss:getJobConf(jobConfController, trigger.jobDataMap["org.dbstar.scheduler.identifier.Identifier"])}' />
			<tr valign="top">
				<td>${trigger.jobDataMap["job.submitter"]}</td>
				<td><c:choose>
					<c:when test='${trigger["class"].simpleName=="CronTriggerImpl"}'>Cron</c:when>
					<c:when test='${trigger["class"].simpleName=="SimpleTriggerImpl"}'>Simple</c:when>
				</c:choose></td>
				<td><c:choose>
					<c:when test='${trigger["class"].simpleName=="CronTriggerImpl"}'>${trigger.cronExpression}</c:when>
					<c:when test='${trigger["class"].simpleName=="SimpleTriggerImpl"}'>${trigger.repeatCount}/${trigger.repeatInterval/1000}</c:when>
				</c:choose></td>
				<td>${trigger.description}</td>
				<td>${conf.type}</td>
				<td><a href="job-conf.action?action=view&identifier=${conf.identifier.stringIdentifier}">${conf.name}</a></td>
				<td>${conf.description}</td>
				<td><c:forEach var="key" items='${trigger.jobDataMap["job.parameters"]}' varStatus="vsk"><c:if test="${vsk.index>0}"><BR></c:if>${key}</c:forEach></td>
				<td>${ss:dateFormat(trigger.startTime.time)}</td>
				<td>${ss:dateFormat(trigger.endTime.time)}</td>
				<td>${ss:dateFormat(trigger.nextFireTime.time)}</td>
				<td>${ss:dateFormat(trigger.previousFireTime.time)}</td>
				<td>${ss:dateFormat(trigger.finalFireTime.time)}</td>
				<td>${trigger.misfireInstruction}</td>
			</tr>
</c:forEach>
		</table>
		<table id="dependency">
			<tr>
				<th rowspan="2">Submitter</th>
				<th rowspan="2">Description</th>
				<th rowspan="2">Keys</th>
				<th rowspan="2">Parameters</th>
				<th colspan="3">Launch Job</th>
				<th colspan="5">Dependency Jobs</th>
				<th rowspan="2">Create<br>Time</th>
			</tr>
			<tr>
				<th>Type</th>
				<th>Name</th>
				<th>Description</th>
				<th>Type</th>
				<th>Name</th>
				<th>Description</th>
				<th>Keys</th>
				<th>Conditions</th>
			</tr>
<c:forEach var="dep" items="${dependencies}">
	<c:set var="conf" value="${ss:getJobConf(jobConfController, dep.jobConfIdentifier)}" />
	<c:forEach var="item" items="${dep.dependencies}" varStatus="vs">
		<c:set var="itemConf" value="${ss:getJobConf(jobConfController, item.identifier)}" />
		<c:choose>
		<c:when test="${vs.index==0}">
			<tr valign="top">
				<td rowspan="${dep.dependencySize}">${dep.owner}</td>
				<td rowspan="${dep.dependencySize}">${dep.description}</td>
				<td rowspan="${dep.dependencySize}"><c:forEach var="key" items="${dep.keys}" varStatus="vsk"><c:if test="${vsk.index>0}"><BR></c:if>${key}</c:forEach></td>
				<td rowspan="${dep.dependencySize}"><c:forEach var="key" items='${dep.parameters}' varStatus="vsk"><c:if test="${vsk.index>0}"><BR></c:if>${key}</c:forEach></td>
				<td rowspan="${dep.dependencySize}">${conf.type}</td>
				<td rowspan="${dep.dependencySize}"><a href="job-conf.action?action=view&identifier=${conf.identifier.stringIdentifier}">${conf.name}</a></td>
				<td rowspan="${dep.dependencySize}">${conf.description}</td>
				<td>${itemConf.type}</td>
				<td><a href="job-conf.action?action=view&identifier=${itemConf.identifier.stringIdentifier}">${itemConf.name}</a></td>
				<td>${itemConf.description}</td>
				<td><c:forEach var="key" items="${dep.keys}" varStatus="vsk"><c:if test="${vsk.index>0}"><BR></c:if>${key}=${item.parameters[key]}</c:forEach></td>
				<td>${item.condition}</td>
				<td rowspan="${dep.dependencySize}">${ss:dateFormat(dep.createTime)}</td>
			</tr>
		</c:when>
		<c:otherwise>
			<tr>
				<td>${itemConf.type}</td>
				<td><a href="job-conf.action?action=view&identifier=${itemConf.identifier.stringIdentifier}">${itemConf.name}</a></td>
				<td>${itemConf.description}</td>
				<td><c:forEach var="key" items="${dep.keys}" varStatus="vsk"><c:if test="${vsk.index>0}"><BR></c:if>${key}=${item.parameters[key]}</c:forEach></td>
				<td>${item.condition}</td>
			</tr>
		</c:otherwise>
	</c:choose></c:forEach>
</c:forEach>
		</table>
<jsp:include page="common/body-footer.jsp"/>
	</body>
</html>
